<style type="text/css">
    .layui-table-body{overflow-x:auto;}
    .layui-table-cell{font-size:12px;}
</style>
<table id="dataTable"></table>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" value="{{ d.status }}" lay-skin="switch" lay-filter="switchStatus" lay-text="正常|关闭" {{ d.status == 1 ? 'checked' : '' }} data-href="{:url('status')}?id={{ d.id }}">
</script>
<script type="text/html" title="操作按钮模板" id="buttonTpl">
    {{# if(d.status == 1){  }}
    <a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger hisi-iframe-pop" hisi-data="{width: '900px', height: '600px', title: '审核'}">审核</a>
    {{# } }}
</script>
{include file="system@block/layui" /}
<script id="toolbar" type="text/html">
    <a href="{:url('add')}" class="layui-btn layui-btn-normal layui-btn-sm hisi-iframe-pop" hisi-data="{width: '900px', height: '600px', title: '添加'}">&nbsp;添加</a>
</script>
<script type="text/javascript">
    layui.use(['table','jquery'], function() {
        var table = layui.table;
        var $ = layui.jquery;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter']
            ,cols: [[ //表头
                {type:'checkbox'}
                ,{field: 'sn', title: '订单编号'}
                ,{field: 'title', title: '报销内容'}
                ,{field: 'class_name', title: '报销分类'}
                ,{field: 'shop_name', title: '门店'}
                ,{field: 'price', title: '金额'}
                ,{field: 'admin_name', title: '提交人'}
                ,{field: 'finance_name', title: '审核人'}
                ,{field: 'bak', title: '备注'}
                ,{field: 'account_name', title: '支出账户'}
                ,{field: 'createtime', title: '创建时间',sort:true}
                ,{field: 'usetime', title: '费用时间'}
                ,{field: 'status', title: '寄存状态', width: 100, templet: function(d){
                    if(d.status == 1){
                        return '<span style="color:red">待审核</span>';
                    }else if(d.status == 2){
                        return '<span>审核通过</span>'
                    }else{
                        return '<span>审核不通过</span>'
                    }

                }}
                ,{title: '操作', width: 120, templet: '#buttonTpl'}
            ]]
            ,done: function(){
                if (typeof(layui.global.addTableTool) !== 'undefined') {
                    layui.global.addTableTool();
                }
            }
        });


        $(document).on('click', '.j-tr-take', function() {
            var that = $(this),
                href = !that.attr('data-href') ? that.attr('href') : that.attr('data-href');
            layer.confirm('确定领取么？', {title:false, closeBtn:0}, function(index){
                if (!href) {
                    layer.msg('请设置data-href参数');
                    return false;
                }
                $.get(href, function(res) {
                    if (res.code == 0) {
                        layer.msg(res.msg);
                    } else {
                        location.reload();
                    }
                });
                layer.close(index);
            });
            return false;
        });
    });
</script>
